package com.tang.model.factorymethod;

import java.util.Objects;

/**
 * @Author tangyuan2meicloud.com
 * @DATE 2021/8/15 12:25
 * @Desc DLC 变量必须被volatile修饰
 * @Remarks
 */
public class JavaCourseFactory implements ICourseFactory {

    private static volatile JavaCourseFactory javaCourseFactory;

    private JavaCourseFactory() {}

    public static JavaCourseFactory getInstance() {
        if (Objects.isNull(javaCourseFactory)) {
            synchronized (JavaCourseFactory.class) {
                if (Objects.isNull(javaCourseFactory)) {
                    javaCourseFactory = new JavaCourseFactory();
                }
            }
        }
        return javaCourseFactory;
    }


    @Override
    public ICourse createInstance() {
        return new JavaCourse();
    }
}
